﻿<%@ page language="java" import="java.util.*,ct.zxd.db.*" pageEncoding="utf-8"
contentType="text/html"
%>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<title></title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
</head>

<%
	String shop = request.getParameter("shopid");
	Dao dao = new Dao();
	
	List<Map<String,Object>>list = dao.getTableByid("dish", shop, null);	
	int count = 0;
	Map<String,Object> lastmap = null;
	if(list.size()>0) {
		lastmap = list.get(list.size()-1);
	}
	if(lastmap!=null){
		String showid = lastmap.get("show_id").toString();
		count = Integer.parseInt(showid);
	}
%>

<body>
  <div class="panel admin-panel">
	  <div class="panel-head"><strong class="icon-reorder"> 库存数为0时，商品不会显示在小程序端</strong></div>
	  <div class="padding border-bottom">  
	  <a class="button button border-yellow" onclick="window.location.href='#add'" href="addadv.jsp?shop=<%=shop%>&flag=add&show=<%=count+1%>" target="add"><span class="icon-plus-square-o"></span> 添加</a>
  </div>
  <table class="table table-hover text-center">
    <tr>
      <th width="7%">编号</th>
      <th width="18%">名称</th>
      <th width="12%">商品图片</th>
      <th width="10%">价格</th>
      <th width="12%">详情图片</th>
      <th width="9%">首页推荐</th>
      <th width="8%">分类</th>
      <th width="24%">操作</th>  <!-- 操作部分宽度最少24%，按钮边线会重合 -->
    </tr>
   
   <%
   	if(list!=null){
       for(Map<String,Object> map : list){
       		String showid = map.get("show_id").toString();
       		String cateName = map.get("name").toString();
       		String imageURL = map.get("imageURL").toString();
       		String price = map.get("price").toString();
       		String introduce = map.get("introduce").toString();
       		String category_name = map.get("category_name").toString();
       		String front = map.get("front").toString();
       %>
   
    <tr>
      <td><%=showid%></td>  
	  <td><%=cateName%></td>   
      <td><img src=<%=imageURL%> alt="" width="70" height="70" /></td>     
      <td><%=price%></td>
      <td><img src=<%=introduce%> alt="" width="70" height="70" /></td>
	  <td>
	  	<input type="checkbox" name="front" value="1" disabled=true <%=front.equals("1") ? "checked" : ""%>/>
	  </td>
	  <td><%=category_name%></td>
      <td><div class="button-group">
      <a class="button border-main" onclick="window.location.href='#add'" href="addadv.jsp?shop=<%=shop%>&show=<%=showid%>&cateName=<%= cateName%>&flag=update" target="add"><span class="icon-edit"></span> 修改</a>
	  <a class="button border-red" onclick="window.location.href='#add'" href="addadv.jsp?shop=<%=shop%>&show=<%=showid%>&cateName=<%= cateName%>&flag=del" target="add"><span class="icon-trash-o"></span> 删除</a>
	  </div></td>
    </tr>
    <%}}%>
    
  </table>
</div>

<div class="panel admin-panel margin-top" id="add">
    <iframe scrolling="auto" rameborder="0" src="addadv.jsp?shop=<%=shop%>" name="add" width="100%" height="100%"></iframe>
</div>
</body></html>